package MR;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class Red extends Reducer<LongWritable, IntWritable, IntWritable, LongWritable>{
    private static IntWritable sort = new IntWritable(1);
    @Override
    protected void reduce(LongWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        for (IntWritable value : values) {
            context.write(sort, key);
            //设置变量每次增1(因为Reduce之前有shuffer,会按照key排序)
            sort.set(sort.get()+1);
        }
    }
}
